package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author moningxi
 */
@Mapper
public interface SetmealDishMapper {
    /**
     * 更据菜品id查询套餐id
     */
    @Select("select setmeal_id from setmeal_dish where dish_id=#{id}")
    List<Long> getIdsByDishId(Long id);

    /**
     * 批量保存套餐菜品
     */
    void saveBatch(List<SetmealDish> setmealDishes);

    /**
     * 更据套餐id查询
     */
    @Select("select * from setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> getBySetmealId(Long id);

    /**
     * 更据套餐id删除
     */
    @Delete("delete from setmeal_dish where setmeal_id=#{id}")
    void deleteBySetmealId(Long id);

    /**
     * 更据套餐id集合批量删除
     */
    void deleteBatchBySetmealId(List<Long> ids);

    /**
     * 更据套餐id获取菜品id集合
     */
    @Select("select dish_id from setmeal_dish where setmeal_id=#{id}")
    List<Long> getDishIdsBySetmealId(Long id);
}
